<?php
	@session_start();
	include("../../connect/connect_mysql.php");
	
function redirect($path){
    header("Location: $path");
}
  
	if ($_FILES['logo_event']['name']!= "") {
		$tempFile = $_FILES['logo_event']['tmp_name'];
		$targetPath = $_SERVER['DOCUMENT_ROOT'] .'/wheelhouse/upload/events/';
		$targetFile =  str_replace('//','/',$targetPath) . $_FILES['logo_event']['name'];
		// Uncomment the following line if you want to make the directory if it doesn't exist
		// mkdir(str_replace('//','/',$targetPath), 0755, true);
		move_uploaded_file($tempFile,$targetFile);
	$path="upload/events/".$_FILES['logo_event']['name'];
	$time= $_POST["group"];
	$date= $_POST["date"];
	$nane = $_POST["name_event"];
	$info = $_POST["info"];
	$info=eregi_replace(chr(13),"",$info);
	$info=str_replace("\n",".-",$info);

	mysql_query ("SET NAMES 'utf8'");
	mysql_query("INSERT INTO `event` (`date`, `time`, `name`, `path`, `info`, `is_deleted`) VALUES ('$date','$time', '$nane', '$path', '$info', '0');");
		redirect('/wheelhouse/admin/?act=event');
	}
	else{
		redirect('/wheelhouse/admin/?act=add_event');
	}

?>